package com.ojoin.trade.common.web.domain;

import java.io.Serializable;

public class Result implements Serializable {
	/**
	 * @fields serialVersionUID 
	 */
	private static final long serialVersionUID = 5905715228490291386L;
	/**
	 * @fields status  状态信息，正确返回OK，否则返回 ERROR，如果返回ERROR则需要填写Message信息
	 */
	private Status status;
	/**
	 * @fields record 消息对象
	 */
	private Object message;
	
	/**
	 * 跳转url
	 */
	private String goUrl;
	
	
	private String code;


	public Result() {
		super();
	}

	/**
	 * @description 
	 * @param status 状态
	 * @param message 消息
	 */
	public Result(Status status, Object message) {
		this.status = status;
		this.message = message;
	}
	
	/**
	 * @description 
	 * @param success 是否成功
	 * @param message 消息
	 */
	public Result(boolean success, Object message,String goUrl) {
		this.status = success?Status.OK:Status.ERROR;
		this.message = message;
		this.goUrl=goUrl;
	}
	
	/**
	 * @description 
	 * @param success 是否成功
	 * @param message 消息
	 */
	public Result(boolean success, Object message) {
		this(success,message,null);
	}
	
	public Result(Status status, String code,Object message) {
		this.status = status;
		this.code=code;
		this.message = message;
	}
	 
	public enum Status {
		OK, ERROR,WARNING
	}

	/**
	 * 添加成功结果信息
	 * @param record
	 */
	public void addOK(Object message) {
		this.message = message;
		this.status = Status.OK;
	}

	/**
	 * 添加错误消息
	 * @param message
	 */
	public void addError(Object message) {
		this.message = message;
		this.status = Status.ERROR;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Object getMessage() {
		return message;
	}

	public void setMessage(Object message) {
		this.message = message;
	}
	
	public String getGoUrl() {
		return goUrl;
	}

	public void setGoUrl(String goUrl) {
		this.goUrl = goUrl;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
}
